//
//  YQSingleton.m
//  iyuanqi
//
//  Created by zhaoliang chen on 2018/10/30.
//  Copyright © 2018 czl. All rights reserved.
//

#import "YQSingletonManager.h"

static YQSingletonManager* shareInstance = nil;

@implementation YQSingletonManager

+ (YQSingletonManager*)getInstance {
    if (shareInstance == nil) {
        @synchronized ([YQSingletonManager class]) {
            if (shareInstance == nil) {
                shareInstance = [[YQSingletonManager alloc]init];
            }
        }
    }
    return shareInstance;
}

+ (instancetype)alloc {
    @synchronized ([YQSingletonManager class]){
        NSAssert(shareInstance == nil,
                 @"Attempted to allocated a second instance");
        shareInstance = [super alloc];
        return shareInstance;
    }
    return nil;
}

- (instancetype)init {
    if (self == [super init]) {
        @synchronized ([YQSingletonManager class]){
            if (self.userObject == nil) {
                self.userObject = [[YQUserInfo alloc]init];
            }
        }
    }
    return self;
}

@end
